package com.juren.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Title:
 * @Description: swagger2配置类
 * @Author: zt
 * @Date: 2019/1/16  17:44
 * @Version:
 */
@Configuration
public class Swagger2 {

    public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.juren.student.controller";
    public static final String VERSION = "1.0.0";

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))//api接口包扫描路径
                .paths(PathSelectors.any())//可以根据url路径设置哪些请求加入文档，忽略哪些请求
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("学生信息相关api文档")
                .description("包含注册查询修改等操作")
                .termsOfServiceUrl("")//设置文档的License信息-> License information
                .version(VERSION)//设置文档的版本信息
                .build();
    }

}
